$(function() {
	$("#datagrid_list")
			.datagrid(
					{
						url : '/oem/list.json',
						rownumbers : true,
						singleSelect : true,
						border : false,
						pagination : true,
						toolbar : '#tb',
						pageSize : 20,
						columns : [ [
								{
									field : "oemId",
									title : "",
									hidden : true
								},
								{
									field : "oemName",
									title : "OEM名称",
									formatter : function(value, rowData,
											rowIndex) {
										return "<a href='/oem/detail?id="
												+ rowData.oemId
												+ "&keepThis=true&amp;TB_iframe=true&amp;height=500&amp;width=850' title='修改OEM-"
												+ value + "' class='thickbox'>"
												+ value + "</a>";
									}
								}, {
									field : "custName",
									title : "经销商"
								}, {
									field : "custUsefulFee",
									title : "可用余额",
									formatter : function(value, row, index) {
										return value.toFixed(2);
									}
								}, {
									field : "oemDomain",
									title : "域名"
								}, {
									field : "oemValidTime",
									title : "有效期"
								}, {
									field : "oemCreatedOn",
									title : "创建日期"
								}, {
									field : "oemServiceTel",
									title : "客服电话"
								} ] ],
						onLoadSuccess : function(data) {
							tb_Reloadinit();
						}
					});

});
function onSelectBegin(date) {
	$('begin').val(date);
}

function onSelectEnd(date) {
	$('end').val(date);
}

function searchit() {
	var name = $.trim($("#name").val());
	var begin = $.trim($("input[name='begin']").val());
	var end = $.trim($("input[name='end']").val());
	if (name == "" && begin == "" && end == "") {
		alert("请输入查询条件!");
		return;
	}
	var opts = $('#datagrid_list').datagrid("options");
	opts.url = "/oem/list.json";
	$('#datagrid_list').datagrid('load', {
		"oemName" : name,
		"oemBegin" : begin,
		"oemEnd" : end
	});
}